//
//  ThirdTableViewCell.m
//  iNews
//
//  Created by lanou3g on 14-12-8.
//  Copyright (c) 2014年 张在青. All rights reserved.
//

#import "ThirdTableViewCell.h"
#import "HomeModel.h"
#import "UIImage+ImageDown.h"
#import "UIImageView+WebCache.h"

@implementation ThirdTableViewCell

- (void)dealloc
{
    [_label release];
    [_leftImv release];
    [_centerImv release];
    [_rightImv release];
    
    [super dealloc];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
       
        
        [self addAllViews];
    }
    return self;
}

- (void)addAllViews
{
    self.label = [[[UILabel alloc] initWithFrame:CGRectMake(5, 5, self.bounds.size.width - 10, 20)] autorelease];
   // self.label.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.label];
    
    self.leftImv = [[[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.label.frame), CGRectGetMaxY(self.label.frame) + 5, ([UIScreen mainScreen].bounds.size.width - 20) / 3.0, 90 - 10 - 5 -  CGRectGetHeight(self.label.frame))] autorelease];
    self.leftImv.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:self.leftImv];
    
    self.centerImv = [[[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.leftImv.frame) + 5, CGRectGetMaxY(self.label.frame) + 5, (self.bounds.size.width - 20) / 3.0, 90 - 10 - 5 -  CGRectGetHeight(self.label.frame))] autorelease];
    self.centerImv.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:self.centerImv];
    
    self.rightImv = [[[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.centerImv.frame) + 5, CGRectGetMaxY(self.label.frame) + 5, (self.bounds.size.width - 20) / 3.0, 90 - 10- 5 -  CGRectGetHeight(self.label.frame))] autorelease];
    self.rightImv.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:self.rightImv];
    
    
}

- (void)writeMessegeWithModel:(HomeModel *)model
{
    
//    NSLog(@"%@",model.imgextra[0]);
//    NSLog(@"%@",model.imgextra[1]);
    self.label.text = model.title;
    
    [self.leftImv sd_setImageWithURL:[NSURL URLWithString:model.imgsrc] placeholderImage:[UIImage imageNamed:@"placehodel.png"]];
    
    [self.centerImv sd_setImageWithURL:[NSURL URLWithString:model.imgextra[0][@"imgsrc"]] placeholderImage:[UIImage imageNamed:@"placehodel.png"]];
    
    [self.rightImv sd_setImageWithURL:[NSURL URLWithString:[model.imgextra lastObject][@"imgsrc"]] placeholderImage:[UIImage imageNamed:@"placehodel.png"]];
}




- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
